package com.imti.secondmenudemo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.imti.secondmenudemo.RightAdapter.RightHolder;
import java.util.List;

public class RightAdapter extends RecyclerView.Adapter<RightHolder>
{

    private Context context;

    private List<RightModel> rightData;

    public RightAdapter(Context context)
    {
        this.context = context;
    }

    public void setRightData(List<RightModel> rightData)
    {
        this.rightData = rightData;
    }

    @NonNull
    @Override
    public RightHolder onCreateViewHolder(
        @NonNull ViewGroup parent, int viewType)
    {
        return new RightHolder(
            LayoutInflater.from(context)
                .inflate(R.layout.right_item, null));
    }

    @Override
    public void onBindViewHolder(
        @NonNull RightAdapter.RightHolder holder, int position)
    {
        holder.rightName.setText(
            rightData.get(position).getName());
    }

    @Override
    public int getItemCount()
    {
        return null == rightData ? 0 : rightData.size();
    }
    class RightHolder extends ViewHolder
    {

        TextView rightName;

        public RightHolder(@NonNull View itemView)
        {
            super(itemView);
            rightName =
                itemView.findViewById(R.id.right_menu_namee);
        }
    }
}
